home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998…tember: Reference Library / Dev.CD Sep 98 RL1.toast / Technical Documentation / develop / develop Issue 27 / develop Issue 27 code / Internet Config Assistant / toolkit / CPoint.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-12  |  1.8 KB  |  112 lines  |  [TEXT/CWIE]

  1.  
  2. #ifndef    __CPOINT__
  3. #define    __CPOINT__
  4.  
  5. #include <Quickdraw.h>
  6.  
  7. class CRect;
  8.  
  9. typedef SInt16 GraphicalUnit;
  10.  
  11. class CPoint
  12. {
  13. public:
  14.     Point fPoint;
  15.  
  16.     // constructors
  17.     inline CPoint();
  18.     inline CPoint(GraphicalUnit X, GraphicalUnit Y);
  19.     inline CPoint(const CPoint& pt);
  20.     inline CPoint(const Point& pt);
  21.     
  22.     // destructor
  23.     inline ~CPoint() {};
  24.  
  25.     // assignment
  26.     CPoint& operator=(const CPoint &from);
  27.     void Set(GraphicalUnit X, GraphicalUnit Y);
  28.  
  29.     void ConstrainTo(const CRect& rect);
  30.         
  31.     // arithmetic
  32.     CPoint operator+(const CPoint&) const;
  33.     CPoint operator-(const CPoint&) const;
  34.     CPoint& operator+=(const CPoint&);
  35.     CPoint& operator-=(const CPoint&);
  36.  
  37.     // relational
  38.     Boolean operator!=(const CPoint&) const;
  39.     Boolean operator==(const CPoint&) const;
  40.     
  41.     // conversion
  42.     inline operator Point*();
  43.     inline operator const Point*() const;
  44.     inline operator Point() const;        
  45.     inline GraphicalUnit X(void) const;    
  46.     inline GraphicalUnit Y(void) const;              
  47. };
  48.  
  49. inline CPoint::CPoint()
  50. {
  51. }
  52.  
  53. inline CPoint::operator Point*()
  54. {
  55.     return &fPoint;
  56. }
  57.  
  58. inline CPoint::operator const Point*() const
  59. {
  60.     return (Point * const)&fPoint;
  61. }
  62.  
  63. inline CPoint::operator Point() const
  64. {
  65.     return fPoint;
  66. }    
  67.  
  68. inline CPoint::CPoint(GraphicalUnit X, GraphicalUnit Y)
  69. {
  70.     fPoint.h = X;
  71.     fPoint.v = Y;
  72. }
  73.  
  74. inline CPoint::CPoint(const CPoint& pt)
  75. {
  76.     fPoint.h = pt.fPoint.h;
  77.     fPoint.v = pt.fPoint.v;
  78. }
  79.  
  80. inline CPoint::CPoint(const Point& pt)
  81. {
  82.     fPoint.h = pt.h;
  83.     fPoint.v = pt.v;
  84. }
  85.  
  86. inline CPoint &CPoint::operator=(const CPoint& from)
  87. {
  88.     // don't need to worry about "this==from"
  89.     fPoint.h = from.fPoint.h;
  90.     fPoint.v = from.fPoint.v;
  91.     return *this;
  92. }
  93.  
  94. inline void CPoint::Set(GraphicalUnit X, GraphicalUnit Y)
  95. {
  96.     fPoint.h = X;
  97.     fPoint.v = Y;
  98. }
  99.  
  100. inline GraphicalUnit CPoint::X(void) const
  101. {
  102.     return fPoint.h;
  103. }
  104.  
  105. inline GraphicalUnit CPoint::Y(void) const
  106. {
  107.     return fPoint.v;
  108. }
  109.  
  110.  
  111. #endif
  112.